The Sound Input Manager provides two routines that allow you to convert between millisecond and byte recording values.
You can use the SPBMilliSecondsToBytes function to determine how many bytes a recording of a certain duration will use.
FUNCTION SPBMilliSecondsToBytes (inRefNum: LongInt;
VAR milliseconds: LongInt):
OSErr;
The SPBMilliSecondsToBytes function reports how many bytes are required to store a recording of duration milliseconds , given the input device's current sample rate, sample size, number of channels, and compression factor.
You can use the SPBBytesToMilliSeconds function to determine the maximum duration of a recording that can fit in a buffer of a certain size.
FUNCTION SPBBytesToMilliSeconds (inRefNum: LongInt;
VAR byteCount: LongInt): OSErr;
The SPBBytesToMilliSeconds function reports how many milliseconds of audio data can be recorded in a buffer that is byteCount bytes long, given the input device's current sample rate, sample size, number of channels, and compression factor.
| Previous | Chapter contents | Chapter top | Section top | Next |